cmake_minimum_required(VERSION 2.8.11)

option(BUILD_EMULATOR "Build with cpp3ds emulator (Qt5 required)" OFF)
option(BUILD_TESTS "Build unit tests" OFF)

# Project name without spaces or special characters
project("cpp3ds-temp-re")

set(APP_TITLE "CPPTemplate")
set(APP_DESCRIPTION "CPP3DS Template 2.0")
set(APP_AUTHOR "arc13")
set(APP_ICON ${PROJECT_SOURCE_DIR}/res/app/icon.png)

# First one is Title Version, second is the readable version
set(APP_VERSION 1024)

# CIA settings
set(APP_UNIQUE_ID 0xC663D) # This must be unique for your CIA project
set(APP_PRODUCT_CODE ${PROJECT_NAME})
set(BANNER_IMAGE ${PROJECT_SOURCE_DIR}/res/app/banner.png)
set(BANNER_SOUND ${PROJECT_SOURCE_DIR}/res/app/banner.wav)
set(ICON_FLAGS --flags visible,ratingrequired,recordusage,savedata --cero 153 --esrb 153 --usk 153 --pegigen 153 --pegiptr 153 --pegibbfc 153 --cob 153 --grb 153 --cgsrr 153)
set(CIA_CONFIG ${PROJECT_SOURCE_DIR}/res/app/cia.rsf)

# Include cpp3ds cmake module
set(CPP3DS $ENV{CPP3DS})
if(NOT CPP3DS)
	message(FATAL_ERROR "You need to set the env variable CPP3DS before compiling.")
endif()
set(CMAKE_MODULE_PATH "${CPP3DS}/cmake" ${CMAKE_MODULE_PATH})
include(cpp3ds)

include_directories(
	${PROJECT_SOURCE_DIR}/external/tween-engine/include
)
FILE(GLOB_RECURSE TWEEN_ENGINE_SOURCE ${PROJECT_SOURCE_DIR}/external/tween-engine/src/*.cpp)

set(SOURCE_FILES
	${PROJECT_SOURCE_DIR}/src/main.cpp
	${PROJECT_SOURCE_DIR}/src/Template.cpp
	${PROJECT_SOURCE_DIR}/src/MusicBCSTM.cpp
	${PROJECT_SOURCE_DIR}/src/Util.cpp
	${PROJECT_SOURCE_DIR}/src/AssetManager.hpp
	${PROJECT_SOURCE_DIR}/src/Notification.cpp
	${PROJECT_SOURCE_DIR}/src/Keyboard/Keyboard.cpp
	${PROJECT_SOURCE_DIR}/src/Keyboard/tinyxml2.cpp
	${PROJECT_SOURCE_DIR}/src/GUI/Button.cpp
	${PROJECT_SOURCE_DIR}/src/GUI/NinePatch.cpp
	${PROJECT_SOURCE_DIR}/src/GUI/Scrollable.cpp
	${PROJECT_SOURCE_DIR}/src/GUI/ScrollBar.cpp
	${PROJECT_SOURCE_DIR}/src/States/State.cpp
	${PROJECT_SOURCE_DIR}/src/States/StateStack.cpp
	${PROJECT_SOURCE_DIR}/src/States/DefaultState.cpp
	${TWEEN_ENGINE_SOURCE}
)

set(ARM_SOURCE_FILES
	${PROJECT_SOURCE_DIR}/src/KeyboardApplet.cpp
)

# Use either nihstro or picasso for your shader scripts
set(SHADER_AS nihstro)
FILE(GLOB_RECURSE SHADER_FILES ${PROJECT_SOURCE_DIR}/res/romfs/shaders/[^.]*.vsh)

##################################################
# Don't usually need to change anything below
##################################################
set(CPP3DS_ARM_FLAGS "-g -O3 -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft")
set(CPP3DS_EMU_FLAGS "-O0")
set(TEST_FLAGS "-O0 -coverage")
include_directories(${DEVKITPRO}/portlibs/armv6k/include)

set(CPP3DS_ARM_LIBS cpp3ds-window cpp3ds-network cpp3ds-graphics cpp3ds-audio cpp3ds-system citro3d ctru freetype png z vorbisidec ogg archive faad fmt)
set(CPP3DS_EMU_LIBS cpp3ds-emu sfml-graphics sfml-window sfml-system sfml-audio openal GLEW GL jpeg freetype vorbisfile vorbis ogg ssl crypto pthread archive faad fmt)

add_subdirectory(${CPP3DS}/cmake/template_arm build/arm)
if(BUILD_EMULATOR)
add_subdirectory(${CPP3DS}/cmake/template_emu build/emu)
endif()
if(BUILD_TESTS)
	add_subdirectory(test)
endif()
